package designpatterns.interpreter;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2/16/2022 7:37 PM
 */
@Slf4j
public class AppTest {

    private Expression getMaleExpression() {
        Expression expression = new TerminalExpression("张三");
        Expression expression1 = new TerminalExpression("李四");
        return new OrExpression(expression, expression1);
    }

    private Expression getMarrieWomanExpression() {
        Expression expression = new TerminalExpression("张青");
        Expression expression1 = new TerminalExpression("李玉");
        return new AndExpression(expression, expression1);
    }

    @Test
    public void test() {
        Expression isMale = getMaleExpression();
        Expression isMarriedWoman = getMarrieWomanExpression();
        log.info("张三是男性吗？ {} ", isMale.interpret("张三"));
        log.info("张青已婚吗？ {} ", isMarriedWoman.interpret("张青"));
        log.info("张青和李玉已婚吗？ {} ", isMarriedWoman.interpret("张青 李玉"));
    }
}
